<template>
	<view>
		<!-- 用户信息 -->
		<view class="user-info">
			<image class="avatar" :src="userInfo.avatarUrl" mode=""></image>
			<text class="nicName">{{userInfo.nickName}}</text>
		</view>
		<!-- 面板列表 -->
		<view class="panel-list">
			<view class="panel-item">
				<view class="panel-content">
					<view class="content-item">
						<text>8</text>
						<text>收藏的店铺</text>
					</view>
					<view class="content-item">
						<text>8</text>
						<text>收藏的商品</text>
					</view>
					<view class="content-item">
						<text>8</text>
						<text>关注的商品</text>
					</view>
					<view class="content-item">
						<text>8</text>
						<text>足迹</text>
					</view>
				</view>
			</view>
			<view class="panel-item">
				<view class="panel-title">
					我的订单
				</view>
				<view class="panel-content">
					<view class="content-item">
						<image src="/static/my-icons/icon1.png" mode=""></image>
						<text>待付款</text>
					</view>
					<view class="content-item">
						<image src="/static/my-icons/icon2.png" mode=""></image>
						<text>代发货</text>
					</view>
					<view class="content-item">
						<image src="/static/my-icons/icon3.png" mode=""></image>
						<text>退款/退货</text>
					</view>
					<view class="content-item">
						<image src="/static/my-icons/icon4.png" mode=""></image>
						<text>全部订单</text>
					</view>
				</view>
			</view>

			<!-- 第三个面板 -->
			<view class="panel-item">
				<view class="list-item">
					<text>收货地址</text>
					<uni-icons type="right"></uni-icons>
				</view>
				<view class="list-item">
					<text>联系客服</text>
					<uni-icons type="right"></uni-icons>
				</view>
				<view class="list-item" @click="logout">
					<text>退出登录</text>
					<uni-icons type="right"></uni-icons>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	export default {
		name: "my-userinfo",
		computed: {
			...mapState('m_user', ['userInfo'])
		},
		data() {
			return {

			};
		},
		methods: {
			...mapMutations('m_user', ['updateToken']),
			//退出登录
			logout() {
				//询问用户
				uni.showModal({
					title: '提示',
					content: '是否退出登录?',
					success: (res) => {
						if (res.confirm) {
							//退出登录 -清空token
							this.updateToken('')
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		height: 100vh;
		background-color: #eee !important;
	}

	.user-info {
		height: 200px;
		background-color: #ea4350;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;

		.avatar {
			width: 90px;
			height: 90px;
			border-radius: 50%;
			border: 2px solid #fff;
			box-shadow: 1 1px 5px #333;
			margin-bottom: 10px;
		}

		.nicName {
			color: #fff;
			font-weight: bold;
		}
	}

	.panel-list {
		padding: 0 6px;
		margin-top: -6px;

		.panel-item {
			background-color: #fff;
			border-radius: 5px;
			padding: 0 6px;
			margin-bottom: 6px;

			.list-item {
				line-height: 40px;
				border-bottom: 1px solid #eee;
				display: flex;
				justify-content: space-between;
				font-style: 14px;
				padding: 0 6px;

				&:last-child {
					border: none
				}
			}

			.panel-title {
				line-height: 48px;
				border-bottom: 1px solid #eee;
				padding-left: 6px;
				font-size: 14px;
			}

			.panel-content {
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 6px 0;

				.content-item {
					display: flex;
					flex-direction: column;
					align-items: center;
					font-size: 12px;

					image {
						width: 35px;
						height: 35px;
					}
				}
			}

		}
	}
</style>
